angular.module("myApp")
.controller("HomeController",["$scope","$http","$state","$interval","globalData",function($scope,$http,$state,$interval,globalData){
	globalData.getHome().success(function(res){
		$scope.h_tagList =[res.tagList[0],res.tagList[1],res.tagList[2]];
		$scope.h_newList =res.newItemList;
		$scope.h_popuList =res.popularItemList;
		$scope.h_topicList =res.topicList;
		$scope.h_cateList =res.cateList;
	});
	//轮播图
	var swiper = new Swiper('.swiper-container', {
        pagination: '.swiper-pagination',
        paginationClickable: true,
        spaceBetween: 0,
        centeredSlides: true,
        autoplay: 1500,
        autoplayDisableOnInteraction: false,
        loop: true
    });
    //倒计时
    $scope.hour="00";
    $scope.min="00";
    $scope.sec="00";
    var endtime=new Date("2017-03-06 22:00:00"),
    	 distime =(endtime-(new Date()))/1000;
    var Interval=$interval(function(){
		$scope.hour=parseInt(distime/3600);
    	$scope.min=parseInt((distime%3600)/60);
    	$scope.sec=parseInt((distime%3600)%60);
    	distime-=1;
    	if(distime<=0){
    		$interval.cancel(Interval);
    		$scope.hour="00";
		    $scope.min="00";
		    $scope.sec="00";
			//distime=22*60*60;
    	}
    },1000);
}]);